﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace ConsoleCasino
{
    public class Program
    {
        static void Main(string[] args)
        {
            //Test
            // Initialise MenuItems, then Menu, then GameManager and check if Start Menu works
            Style style = new Style(new Point(20, 20), ConsoleColor.White, ConsoleColor.Black);
            Style style2 = new Style(new Point(35, 20), ConsoleColor.White, ConsoleColor.Black);
            MenuChanger newGame = new MenuChanger("New Game", style);
            MenuChanger loadGame = new MenuChanger("Load Game", style2);
            MenuItem[] menuItems = { newGame, loadGame };
            Menu startMenu = new Menu("Start Menu", menuItems);
            Menu newGameMenu = new Menu("New Game", new MenuItem[] { new PlayerControl() });
            Menu[] menus = { startMenu, newGameMenu };
            GameManager.AddMenus(menus);
            Menu current = GameManager.GetCurrent();
            GameManager.CurrentPlayer = new Player("Pesho", Sex.Male);
            GameManager.Subscribe((MenuChanger)current.MenuItems[0]);
            Draw.DrawMenu(current);
            while (true)
            {
                PlayerInput input = GameManager.CurrentPlayer.GetInput();
                current.CheckInput(input);
                // TODO: The console screen clears when the player makes a move, but not when there is change from the computer.
                // Change screen works
                if (GameManager.Message != "")
                {
                    if (GameManager.Message == "player input")
                    {
                        Console.Clear();
                        Draw.DrawMenu(GameManager.GetCurrent());
                        GameManager.GetCurrent().MenuItems[0].Perform();
                    }
                    GameManager.Message = "";
                }
                if (input != PlayerInput.Idle)
                {
                    Console.Clear();
                    Draw.DrawMenu(GameManager.GetCurrent());
                }
            }
        }
    }
}
